import { createRouter, createWebHashHistory } from 'vue-router'

import layout from '@/views/Layout/index.vue'
import login from '@/views/login/index.vue'
import home from '@/views/home/index.vue'
import category from '@/views/category/index.vue'
import product from '@/views/product/index.vue'
import cart from '@/views/cart/index.vue'
import checkout from '@/views/checkout/index.vue'
import pay from '@/views/pay/index.vue'
import result from '@/views/result/index.vue'

const routes = [
  {
    path: '/',
    component: layout,
    children: [
      {
        path: '',
        component: home
      },
      {
        path: 'category/:id',
        component: category
      },
      {
        path: 'product/:id',
        component: product
      },
      {
        path: 'cart',
        component: cart
      },
      {
        path: 'checkout',
        component: checkout
      },
      {
        path: 'pay',
        component: pay
      },
      {
        path: 'pay/result',
        component: result
      }
    ]
  },
  {
    path: '/login',
    component: login
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

export default router
